package com.zimmur.service.impl.account;

import javax.annotation.Resource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import com.zimmur.dao.account.IUserCommentDao;
import com.zimmur.model.account.UserComment;
import com.zimmur.service.account.IUserCommentService;
import com.zimmur.tools.DateUtils;
@Service("userCommentService")
public class UserCommentServiceImpl implements IUserCommentService{
	private static Logger log = LoggerFactory.getLogger(UserCommentServiceImpl.class);
	@Resource
	private IUserCommentDao userCommentDao;
	@Override
	public int updateComment(UserComment userComment) {
		
		return userCommentDao.updateByPrimaryKeySelective(userComment);
	}
	@Override
	public UserComment selectCommentByUserId(long userId) {
		UserComment userComment=userCommentDao.selectByUserId(userId);
		if(userComment==null){
			userComment=new UserComment();
			userComment.setUserId(userId);
			userComment.setUpdateTime(DateUtils.getNowUnixTime());
			userCommentDao.insertSelective(userComment);
		}
		return userComment;
	}
}
